﻿Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Collections.Generic

Imports DotNetNuke
Imports DotNetNuke.Security
Imports Insurance
Imports DotNetNuke.Entities.Modules

Namespace DotNetNuke.Modules.Insurance
    Partial Class ManageInsurance
        Inherits PortalModuleBase

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            LoadDataForRepeater()
        End Sub

        'Get data and binding into repeater
        Private Sub LoadDataForRepeater()
            Dim context As InsuranceDataContext = New InsuranceDataContext()
            Dim lstInsurance = (From p In context.cwc_Insurances _
                                Order By p.company _
                         Select New InsuranceDTO With {.InsuranceId = p.insuranceID, .InsuranceName = p.company}).ToList()
            rptListInsurance.DataSource = lstInsurance
            rptListInsurance.DataBind()

        End Sub
        Protected Sub rptListInsurance_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptListInsurance.ItemCommand
            Me.Response.Redirect("Default.aspx?TabId=" + Me.TabId.ToString + "&iid=" & e.CommandArgument.ToString() + "&go=EditInsurance")
        End Sub

        Protected Sub btnAddNew_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAddNew.Click
            Me.Response.Redirect("Default.aspx?TabId=" + Me.TabId.ToString + "&go=EditInsurance")
        End Sub
    End Class
    Public Class InsuranceDTO
        Private _insuranceId As Integer
        Public Property InsuranceId() As Integer
            Get
                Return _insuranceId
            End Get
            Set(ByVal value As Integer)
                _insuranceId = value
            End Set
        End Property
        Private _insuranceName As String
        Public Property InsuranceName() As String
            Get
                Return _insuranceName
            End Get
            Set(ByVal value As String)
                _insuranceName = value
            End Set
        End Property
    End Class
End Namespace

